package com.yykj.pay.server.repository;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yykj.pay.server.entity.ClientPayConfig;
import com.yykj.pay.server.exception.ErrorCode;
import com.yykj.pay.server.exception.ErrorCodeException;
import org.apache.ibatis.annotations.Mapper;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author zengg
 * @since 2022-04-08
 */
@Mapper
public interface ClientPayConfigMapper extends BaseMapper<ClientPayConfig> {

    default ClientPayConfig findByClientId(String hospitalId) {
        LambdaQueryWrapper<ClientPayConfig> c = new LambdaQueryWrapper<>();
        c.eq(ClientPayConfig::getClientId, hospitalId);
        ClientPayConfig clientPayConfig = this.selectOne(c);
        if (clientPayConfig == null) {
            throw new ErrorCodeException(ErrorCode._9014);
        }
        return clientPayConfig;
    }

}
